# $Id: PKGBUILD 83527 2013-02-02 13:35:30Z mtorromeo $
# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Daniele Paolella <dp@mcrservice.it>

pkgname=supervisor
pkgver=3.0a12
pkgrel=4
pkgdesc="A system for controlling process state under UNIX"
arch=('any')
url="http://supervisord.org"
license=('custom')
depends=('python2-meld3')
makedepends=('python2-distribute')
backup=('etc/supervisord.conf')
source=("http://pypi.python.org/packages/source/s/$pkgname/$pkgname-$pkgver.tar.gz"
        'supervisord'
        'supervisord.service'
        'supervisor.logrotate'
        'supervisord.conf')

build() {
	cd "$srcdir/$pkgname-$pkgver"
	rm -rf "supervisor/medusa/"{debian,demo,docs,test}
	find -type f -name "*.py" -exec sed -i 's|/usr/bin/env python|/usr/bin/env python2|' {} \;
	python2 setup.py build
}

package() {
	cd "$srcdir/$pkgname-$pkgver"
    python2 setup.py install -O1 --skip-build --prefix=/usr --root="$pkgdir"

	install -Dm600 "$srcdir/supervisord.conf" "$pkgdir/etc/supervisord.conf"
	install -Dm755 "$srcdir/supervisord" "$pkgdir/etc/rc.d/supervisord"
	install -Dm644 "$srcdir/supervisor.logrotate" "$pkgdir/etc/logrotate.d/supervisor"
	install -Dm644 "$srcdir/supervisord.service" "$pkgdir/usr/lib/systemd/system/supervisord.service"
	install -d "$pkgdir/usr/share/licenses/$pkgname"
	install -d "$pkgdir/var/log/$pkgname"
	install -d "$pkgdir/etc/supervisor.d"
	mv LICENSES.txt COPYRIGHT.txt "$pkgdir/usr/share/licenses/$pkgname"
}

sha256sums=('de60eee3c460b379aa8493083b59d31b29f2c4267730db29b6f9dea22642b3b4'
            '41f73c313b945949cadc3e000245dbff601072bea5717113e850368678cf52e2'
            '7c83b32ccd256a08b323ed972cff25ad29d44b18b1138624c74ead4929809676'
            '7347d79c8b7f5cc59d5ffa31e4df64f92e89dee0dc84bdb3bdfcba212de93f4b'
            'fe0a60e34f67bf6ed7ca8731d9ce7657e00f37a43e0dfb96aa0df57adc4cd423')
